﻿<Window x:Class="Miris.HumanMilkAnalyser.WPF.AnalysisReportDesignWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:userControl="clr-namespace:Miris.HumanMilkAnalyser.WPF.CustomizedUserControl"
        WindowStartupLocation="CenterScreen"
        WindowStyle="ToolWindow" 
        AllowsTransparency="False"
        WindowState="Normal"
        BorderBrush="#13248b"
        BorderThickness="6"
        Title="AnalysisReportDesignWindow" Height="1122.56" Width="793.76">
    <Grid Margin="20" Width="758" Height="1100">
        <Grid.RowDefinitions>
            <!-- Logo, Header & Title -->
            <RowDefinition Height="90" />
            <!-- Patient Number, Milk Sample & Analysis Date -->
            <RowDefinition Height="25" />
            <!-- Baby & Monther Info -->
            <RowDefinition Height="Auto" />
            <!-- Analysis Result Indicator -->
            <RowDefinition Height="40" />
            <!-- Result Chart -->
            <RowDefinition Height="Auto" />
            <!-- History Data Title -->
            <RowDefinition Height="30" />
            <!-- History Data List -->
            <RowDefinition Height="Auto" />
            <!-- Diagnostic Message -->
            <RowDefinition Height="Auto" />
            <!-- Footer -->
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <!-- Logo -->
                <ColumnDefinition Width="Auto" />
                <!-- Report Title -->
                <ColumnDefinition />
                <!-- Analysis Report Title -->
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Margin="0,0,2,0" Source="{Binding CompanyLogoFileFullName}" VerticalAlignment="Top" Height="60" />
            <StackPanel Grid.Column="1">
                <TextBlock Text="{Binding CompanyName}" Style="{StaticResource AnalysisReportTitleTextBlock}" />
                <TextBlock Text="{Binding CompanyAddress}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                <TextBlock Text="{Binding CompanyPhoneNumber}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
            </StackPanel>
            <Image Grid.Column="2" Margin="0,0,-25,0" VerticalAlignment="Top" Source="/Skins/Resource/Image/SystemTitle.png" Width="300" />
        </Grid>
        <StackPanel Grid.Row="1" Orientation="Horizontal">
            <TextBlock Text="受测者ID：" Style="{StaticResource AnalysisReportBlueTextBlock}" />
            <TextBlock Margin="0,0,50,0" Text="{Binding Number}" Style="{StaticResource AnalysisReportBlueTextBlock}" />
            <TextBlock Text="取奶样本：" Style="{StaticResource AnalysisReportBlueTextBlock}" />
            <TextBlock Margin="0,0,50,0" Style="{StaticResource AnalysisReportBlueTextBlock}">
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0} {1}">
                        <Binding Path="CurrentMilkStageDisplay" />
                        <Binding Path="CurrentMilkSampleDisplay"/>
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
            <TextBlock Text="检测时间：" Style="{StaticResource AnalysisReportBlueTextBlock}" />
            <TextBlock Text="{Binding AllTestResults.TestDateDisplay}" Style="{StaticResource AnalysisReportBlueTextBlock}" />
        </StackPanel>
        <Border Grid.Row="2" Style="{StaticResource AnalysisReportItemContainerBorder}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <!-- Baby Info -->
                    <ColumnDefinition />
                    <!-- Separator -->
                    <ColumnDefinition Width="1" />
                    <!-- Mother Info -->
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Border Height="30" Style="{StaticResource AnalysisReportItemTitleBorder}">
                        <TextBlock Text="婴儿信息" TextAlignment="Center" Style="{StaticResource AnalysisReportItemTitleTextBlock}" />
                    </Border>
                    <Grid Grid.Row="1" Height="150">
                        <Grid Margin="4">
                            <Grid.ColumnDefinitions>
                                <!-- Label -->
                                <ColumnDefinition Width="Auto" />
                                <!-- Info -->
                                <ColumnDefinition />
                                <!-- Label -->
                                <ColumnDefinition Width="Auto" />
                                <!-- Info -->
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                            </Grid.RowDefinitions>
                            <TextBlock Text="姓名：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Text="{Binding BabyName}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Text="出生日期：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Text="{Binding BabyBirthdayDisplay}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="1" Text="身长(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding BabyHeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Grid.Row="1" Text="体重(KG)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Grid.Row="1" Text="{Binding BabyWeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="2" Text="头围(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding BabyHeadCircumference}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Grid.Row="2" Text="出生身长(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Grid.Row="2" Text="{Binding BabyBirthHeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="3" Text="性别：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding BabyGenderDisplay}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Grid.Row="3" Text="是否早产：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Grid.Row="3" Text="{Binding IsBabyPrematureDeliveryDisplay}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="4" Text="出生体重(KG)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding BabyBirthWeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Grid.Row="4" Text="出生头围(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Grid.Row="4" Text="{Binding BabyBirthHeadCircumference}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="5" Text="Apgar评分：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="5" Text="{Binding Apgar}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                        </Grid>
                    </Grid>
                </Grid>
                <Border Grid.Column="1" Grid.RowSpan="2" Background="#0f1d7a" />
                <Grid Grid.Column="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Border Height="30" Style="{StaticResource AnalysisReportItemTitleBorder}">
                        <TextBlock Text="母亲信息" TextAlignment="Center" Style="{StaticResource AnalysisReportItemTitleTextBlock}" />
                    </Border>
                    <Grid Grid.Row="1" Height="150">
                        <Grid Margin="4">
                            <Grid.ColumnDefinitions>
                                <!-- Label -->
                                <ColumnDefinition Width="Auto" />
                                <!-- Info -->
                                <ColumnDefinition />
                                <!-- Label -->
                                <ColumnDefinition Width="Auto" />
                                <!-- Info -->
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="22" />
                            </Grid.RowDefinitions>
                            <TextBlock Text="姓名：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Text="{Binding MotherName}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Text="年龄：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Text="{Binding MotherAge}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="1" Text="身高(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding MotherHeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Grid.Row="1" Text="体重(KG)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Grid.Row="1" Text="{Binding MotherWeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="2" Text="BMI：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding MotherBMI,StringFormat={}{0}(18.5～24)}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Grid.Row="2" Text="分娩方式：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Grid.Row="2" Text="{Binding MotherDeliveryMode}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="3" Text="开奶时间：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding MotherOpenMilkDateDisplay}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="2" Grid.Row="3" Text="情绪：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="3" Grid.Row="3" Text="{Binding MotherEmotion}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Row="4" Text="不良习惯：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                            <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding MotherBadHabit}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                        </Grid>
                    </Grid>
                </Grid>
            </Grid>
        </Border>
        <StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center">
            <TextBlock Margin="0,0,30,0" VerticalAlignment="Center" Text="检测结果" Style="{StaticResource AnalysisReportBlueTextBlock}" />
            <Border Margin="0,0,5,0" Background="#0f1d7a" Style="{StaticResource AnalysisReportAnalysisResultIndicatorBorder}" />
            <TextBlock Margin="0,0,20,0" FontSize="16" VerticalAlignment="Center" Text="偏低" Foreground="Black" Style="{StaticResource AnalysisReportBlueTextBlock}" />
            <Border Margin="0,0,5,0" Background="#a4a4a4" Style="{StaticResource AnalysisReportAnalysisResultIndicatorBorder}" />
            <TextBlock Margin="0,0,20,0" FontSize="16" VerticalAlignment="Center" Text="正常" Foreground="Black" Style="{StaticResource AnalysisReportBlueTextBlock}" />
            <Border Margin="0,0,5,0" Background="#c1101c" Style="{StaticResource AnalysisReportAnalysisResultIndicatorBorder}" />
            <TextBlock VerticalAlignment="Center" FontSize="16" Text="偏高" Foreground="Black" Style="{StaticResource AnalysisReportBlueTextBlock}" />
        </StackPanel>
        <StackPanel Grid.Row="4">
            <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.Fat}" Height="75" Margin="0,0,0,10" />
            <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.CrudeProtein}" Height="75" Margin="0,0,0,10" />
            <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.Carbohydrate}" Height="75" Margin="0,0,0,10" />
            <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.TS}" Height="75" Margin="0,0,0,10" />
            <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.Energy}" Height="75" />
        </StackPanel>
        <TextBlock Grid.Row="5" Text="历史记录" VerticalAlignment="Center" Style="{StaticResource AnalysisReportBlueTextBlock}" />
        <DataGrid Grid.Row="6" SelectionMode="Single" BorderThickness="1" BorderBrush="#0f1d7a" FontSize="14"
                  HorizontalAlignment="Left" Height="150" Width="758" ItemsSource="{Binding AnalysisResultList}">
            <DataGrid.ColumnHeaderStyle>
                <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource DefaultDataGridColumnHeader}">
                    <Setter Property="FontSize" Value="15" />
                    <Setter Property="Height" Value="26" />
                </Style>
            </DataGrid.ColumnHeaderStyle>
            <DataGrid.Columns>
                <DataGridTextColumn Header="序号" Width="50" Binding="{Binding SequenceNumber}" />
                <DataGridTextColumn Header="测试时间" Width="120"  Binding="{Binding TestDateDisplay}" />
                <DataGridTextColumn Header="母乳取样" Width="80" Binding="{Binding SampleType}" />
                <DataGridTextColumn Header="母乳分期" Width="80" Binding="{Binding SampleStage}" />
                <DataGridTextColumn Header="脂肪" Width="50" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding Fat.TestResult}" />
                <DataGridTextColumn Header="总蛋白质" Width="75" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding CrudeProtein.TestResult}" />
                <DataGridTextColumn Header="真蛋白质" Width="75" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding TrueProtein.TestResult}" />
                <DataGridTextColumn Header="糖类" Width="50" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding Carbohydrate.TestResult}" />
                <DataGridTextColumn Header="干物质" Width="60" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding TS.TestResult}" />
                <DataGridTextColumn Header="总能量" Width="60" ElementStyle="{StaticResource TestResultDataGridCell}" Binding="{Binding Energy.TestResult}" />
            </DataGrid.Columns>
        </DataGrid>
        <Grid Grid.Row="7">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="250" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Border Height="30" Style="{StaticResource AnalysisReportItemTitleBorder}">
                <TextBlock Text="指导意见" TextAlignment="Center" Style="{StaticResource AnalysisReportItemTitleTextBlock}" />
            </Border>
            <Border Grid.Row="1" BorderThickness="1" BorderBrush="#0f1d7a" Height="80">
                <TextBlock Margin="3" VerticalAlignment="Top" Text="{Binding DiagnosticMessages}" TextWrapping="Wrap" Style="{StaticResource AnalysisReportBlackTextBlock}" />
            </Border>
            <Grid Grid.Column="1" Grid.RowSpan="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Border BorderThickness="0,1,1,1" BorderBrush="#0f1d7a">
                    <StackPanel>
                        <TextBlock Margin="3" FontSize="16" Text="科室" HorizontalAlignment="Center" Style="{StaticResource AnalysisReportBlueTextBlock}" />
                        <TextBlock Margin="3" FontSize="16" Text="{Binding DepartmentName}" HorizontalAlignment="Center" Style="{StaticResource AnalysisReportBlueTextBlock}" />
                    </StackPanel>
                </Border>
                <Border Grid.Column="1" BorderThickness="0,1,1,1" BorderBrush="#0f1d7a">
                    <TextBlock Margin="3" FontSize="16" Text="操作员" HorizontalAlignment="Center" Style="{StaticResource AnalysisReportBlueTextBlock}" />
                </Border>
            </Grid>
        </Grid>
        <TextBlock Grid.Row="8" Text="本测量结果仅供临床医生参考，不作为诊断报告。" VerticalAlignment="Bottom" Style="{StaticResource AnalysisReportBlackTextBlock}" />
    </Grid>
</Window>
